<template><div><p>本文档最新版为 <a href="https://learnku.com/docs/laravel/10.x" target="_blank" rel="noopener noreferrer">10.x</a>，旧版本可能放弃维护，推荐阅读最新版！</p>
<h2 id="laravel-的契约-contracts" tabindex="-1"><a class="header-anchor" href="#laravel-的契约-contracts"><span>Laravel 的契约 (Contracts)</span></a></h2>
<ul>
<li><a href="#introduction">简介</a>
<ul>
<li><a href="#contracts-vs-facades">契约 VS Facades</a></li>
</ul>
</li>
<li><a href="#when-to-use-contracts">何时使用契约</a>
<ul>
<li><a href="#loose-coupling">低耦合</a></li>
<li><a href="#simplicity">简单性</a></li>
</ul>
</li>
<li><a href="#how-to-use-contracts">如何使用契约</a></li>
<li><a href="#contract-reference">契约参考</a></li>
</ul>
<h2 id="简介" tabindex="-1"><a class="header-anchor" href="#简介"><span>简介</span></a></h2>
<p>Laravel 的契约是一组定义框架提供的核心服务的接口。例如，<code v-pre>Illuminate\Contracts\Queue\Queue</code> 契约定义了队列任务所需的方法，而 <code v-pre>Illuminate\Contracts\Mail\Mailer</code> 契约定义了发送电子邮件所需的方法。</p>
<p>框架对每个契约都提供了相应的实现。例如，Laravel 提供了具有各种驱动的队列实现和由 <a href="http://swiftmailer.org/" target="_blank" rel="noopener noreferrer">SwiftMailer</a> 提供支持的邮件驱动实现。</p>
<p>所有的 Laravel 契约都有他们自己的 <a href="https://github.com/illuminate/contracts" target="_blank" rel="noopener noreferrer">GitHub 库</a>。这为所有可用的契约提供了一个快速参考指南，同时也可单独作为低耦合的扩展包给其他包开发者使用。</p>
<h3 id="契约-vs-facades" tabindex="-1"><a class="header-anchor" href="#契约-vs-facades"><span>契约 VS Facades</span></a></h3>
<p>Laravel <a href="https://learnku.com/docs/laravel/5.5/facades" target="_blank" rel="noopener noreferrer">Facades</a> 和辅助函数提供了一种使用 Laravel 服务的简单方法，即不需要通过类型提示并从服务容器中解析契约。在大多数情况下，每个 Facades 都有一个等效的契约。</p>
<p>不像 Facades，不需要你在类的构造函数中类型提示，契约则需要你在类中明显地定义依赖项。一些开发者倾向于以契约这种方式明确地定义它们的依赖项，而其它开发者则更喜欢 Facades 带来的便捷。</p>
<blockquote>
<p>{tip} 对于大多数应用程序来说不管是使用Facades还是契约都可以。但是，如果你正在构建一个扩展包，为了方便测试，你应该强烈考虑契约。</p>
</blockquote>
<h2 id="何时使用契约" tabindex="-1"><a class="header-anchor" href="#何时使用契约"><span>何时使用契约</span></a></h2>
<p>综上所述，使用契约或是 Facades 很大程度上归结于个人或者开发团队的喜好。不管是契约还是 Facades 都可以创建出健壮的、易测试的 Laravel 应用程序。如果你长期关注类的单一职责，你会注意到使用契约还是 Facades 其实没多少实际意义上的区别。</p>
<p>然而，你可能还是会有几个关于契约的问题。例如，为什么要使用接口？不使用接口会比较复杂吗？下面让我们谈下使用接口的原因：低耦合和简单性。</p>
<h3 id="低耦合" tabindex="-1"><a class="header-anchor" href="#低耦合"><span>低耦合</span></a></h3>
<p>首先，让我们来看一些高耦合缓存实现的代码。如下:</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Orders</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Repository</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 缓存实例。</span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$cache</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 创建一个仓库实例。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token punctuation">\</span>SomePackage<span class="token punctuation">\</span>Cache<span class="token punctuation">\</span>Memcached</span>  <span class="token parameter">$cache</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">__construct</span><span class="token punctuation">(</span><span class="token class-name class-name-fully-qualified type-declaration"><span class="token punctuation">\</span>SomePackage<span class="token punctuation">\</span>Cache<span class="token punctuation">\</span>Memcached</span> <span class="token variable">$cache</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">cache</span> <span class="token operator">=</span> <span class="token variable">$cache</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 按照 Id 检索订单</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">int</span></span>  <span class="token parameter">$id</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name">Order</span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">find</span><span class="token punctuation">(</span><span class="token variable">$id</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$this</span><span class="token operator">-></span><span class="token property">cache</span><span class="token operator">-></span><span class="token function">has</span><span class="token punctuation">(</span><span class="token variable">$id</span><span class="token punctuation">)</span><span class="token punctuation">)</span>    <span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">//</span></span>
<span class="line">        <span class="token punctuation">}</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在这个类中，程序跟给定的缓存实现高耦合。因为我们依赖于一个扩展包的特定缓存类。一旦这个扩展包的 API 被更改了，我们的代码就必须跟着改变。</p>
<p>同样的，如果我们想要将底层的的缓存技术（ Memcached ）替换为另一种缓存技术（ Redis ），那又得再次修改这个 <code v-pre>repository</code> 类。而 <code v-pre>repository</code> 类不应该了解太多关于谁提供了这些数据或是如何提供的等等。</p>
<p><strong>比起上面的做法，我们可以使用一个简单的、与扩展包无关的接口来改进我们的代码：</strong></p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Orders</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Contracts<span class="token punctuation">\</span>Cache<span class="token punctuation">\</span>Repository</span> <span class="token keyword">as</span> Cache<span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">Repository</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 缓存实例。</span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$cache</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 创建一个仓库实例。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name">Cache</span>  <span class="token parameter">$cache</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">__construct</span><span class="token punctuation">(</span><span class="token class-name type-declaration">Cache</span> <span class="token variable">$cache</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">cache</span> <span class="token operator">=</span> <span class="token variable">$cache</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>现在，更改之后的代码没有与任何扩展包甚至是 Laravel 耦合。而契约扩展包不包含任何实现和依赖项，你可以轻松地写任何给定契约的替代实现，来实现不修改任何关于缓存消耗的代码就可以替换缓存实现。</p>
<h3 id="简单性" tabindex="-1"><a class="header-anchor" href="#简单性"><span>简单性</span></a></h3>
<p>当所有 Laravel 的服务都使用简洁的接口定义，就很容易判断给定服务提供的功能。 <strong>可以将契约视为说明框架功能的简洁文档。</strong></p>
<p>除此之外，当依赖的接口足够简洁时，代码的可读性和可维护性会大大提高。比起搜索一个大型复杂的类中有哪些可用的方法，不如检索一个简单、 干净的接口来参考更妥当。</p>
<h2 id="如何使用契约" tabindex="-1"><a class="header-anchor" href="#如何使用契约"><span>如何使用契约</span></a></h2>
<p>那么，如何获得一个契约的实现呢？这其实很简单～</p>
<p>Laravel 中的许多类型的类都是通过 <a href="https://learnku.com/docs/laravel/5.5/container" target="_blank" rel="noopener noreferrer">服务容器</a> 解析出来的，包括控制器、事件监听器、中间件、任务队列，甚至路由闭包。所以说，要获得一个契约的实现，你只需要被解析的类的构造函数中添加「类型提示」即可。</p>
<p>例如，看看这个事件监听器：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">App<span class="token punctuation">\</span>Listeners</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">App<span class="token punctuation">\</span>User</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">App<span class="token punctuation">\</span>Events<span class="token punctuation">\</span>OrderWasPlaced</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Illuminate<span class="token punctuation">\</span>Contracts<span class="token punctuation">\</span>Redis<span class="token punctuation">\</span>Database</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">CacheOrderInformation</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * Redis 数据库实现。</span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">protected</span> <span class="token variable">$redis</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 创建事件处理器实例。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name">Database</span>  <span class="token parameter">$redis</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">__construct</span><span class="token punctuation">(</span><span class="token class-name type-declaration">Database</span> <span class="token variable">$redis</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">redis</span> <span class="token operator">=</span> <span class="token variable">$redis</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 处理事件。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name">OrderWasPlaced</span>  <span class="token parameter">$event</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">handle</span><span class="token punctuation">(</span><span class="token class-name type-declaration">OrderWasPlaced</span> <span class="token variable">$event</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token comment">//</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>当事件监听器被解析时，服务容器会读取类的构造函数上的类型提示，并注入对应的值。想了解更多关于服务容器的注册，请查看 <a href="https://learnku.com/docs/laravel/5.5/container" target="_blank" rel="noopener noreferrer">其文档</a>。</p>
<h2 id="契约参考" tabindex="-1"><a class="header-anchor" href="#契约参考"><span>契约参考</span></a></h2>
<p>下表提供了所有 Laravel 契约及其对应的 Facade：</p>
<table>
<thead>
<tr>
<th>Contract</th>
<th>References Facade</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Auth/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Auth\Factory</a></td>
<td>Auth</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Auth/PasswordBroker.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Auth\PasswordBroker</a></td>
<td>Password</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Bus/Dispatcher.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Bus\Dispatcher</a></td>
<td>Bus</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Broadcasting/Broadcaster.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Broadcasting\Broadcas...</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Cache/Repository.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Cache\Repository</a></td>
<td>Cache</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Cache/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Cache\Factory</a></td>
<td>Cache::driver()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Config/Repository.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Config\Repository</a></td>
<td>Config</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Container/Container.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Container\Container</a></td>
<td>App</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Cookie/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Cookie\Factory</a></td>
<td>Cookie</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Cookie/QueueingFactory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Cookie\QueueingFactor...</a></td>
<td>Cookie::queue()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Encryption/Encrypter.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Encryption\Encrypter</a></td>
<td>Crypt</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Events/Dispatcher.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Events\Dispatcher</a></td>
<td>Event</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Filesystem/Cloud.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Filesystem\Cloud</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Filesystem/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Filesystem\Factory</a></td>
<td>File</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Filesystem/Filesystem.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Filesystem\Filesystem</a></td>
<td>File</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Foundation/Application.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Foundation\Applicatio...</a></td>
<td>App</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Hashing/Hasher.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Hashing\Hasher</a></td>
<td>Hash</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Logging/Log.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Logging\Log</a></td>
<td>Log</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Mail/MailQueue.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Mail\MailQueue</a></td>
<td>Mail::queue()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Mail/Mailer.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Mail\Mailer</a></td>
<td>Mail</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Queue/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Queue\Factory</a></td>
<td>Queue::driver()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Queue/Queue.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Queue\Queue</a></td>
<td>Queue</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Redis/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Redis\Factory</a></td>
<td>Redis</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Routing/Registrar.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Routing\Registrar</a></td>
<td>Route</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Routing/ResponseFactory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Routing\ResponseFacto...</a></td>
<td>Response</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Routing/UrlGenerator.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Routing\UrlGenerator</a></td>
<td>URL</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Support/Arrayable.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Support\Arrayable</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Support/Jsonable.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Support\Jsonable</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Support/Renderable.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Support\Renderable</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Validation/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Validation\Factory</a></td>
<td>Validator::make()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/Validation/Validator.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\Validation\Validator</a></td>
<td></td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/View/Factory.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\View\Factory</a></td>
<td>View::make()</td>
</tr>
<tr>
<td><a href="https://github.com/illuminate/contracts/blob/laravel/5.5/View/View.php" target="_blank" rel="noopener noreferrer">Illuminate\Contracts\View\View</a></td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="译者署名" tabindex="-1"><a class="header-anchor" href="#译者署名"><span>译者署名</span></a></h2>
<table>
<thead>
<tr>
<th>用户名</th>
<th>头像</th>
<th>职能</th>
<th>签名</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/iwzh" target="_blank" rel="noopener noreferrer">@iwzh</a></td>
<td><img src="https://cdn.learnku.com/uploads/avatars/3762_1456807721.jpeg?imageView2/1/w/200/h/200" alt="200"></td>
<td>翻译</td>
<td>码不能停 <a href="https://github.com/iwzh" target="_blank" rel="noopener noreferrer">@iwzh</a> at Github</td>
</tr>
<tr>
<td><a href="https://learnku.com/users/5350" target="_blank" rel="noopener noreferrer">@JokerLinly</a></td>
<td><img src="https://cdn.learnku.com/uploads/avatars/5350_1481857380.jpg" alt="5350_1481857380.jpg"></td>
<td>Review</td>
<td>Stay Hungry. Stay Foolish.</td>
</tr>
</tbody>
</table>
<hr>
<blockquote>
<p>{note} 欢迎任何形式的转载，但请务必注明出处，尊重他人劳动共创开源社区。</p>
<p>转载请注明：本文档由 Laravel China 社区 <a href="https://laravel-china.org/" target="_blank" rel="noopener noreferrer">laravel-china.org</a> 组织翻译，详见 <a href="https://learnku.com/laravel/t/5756/laravel-55-document-translation-call-come-and-join-the-translation" target="_blank" rel="noopener noreferrer">翻译召集帖</a>。</p>
<p>文档永久地址： <a href="https://learnku.com/docs/laravel" target="_blank" rel="noopener noreferrer">《Laravel 中文文档》</a></p>
</blockquote>
</div></template>


